<template>
  <div class="app-container el-card is-always-shadow">
    <div class="el-card__header">
      <div slot="header" class="clearfix">
        <span>
          标题
        </span>
      </div>
    </div>
    <div class="el-card__body">
      <el-form
        :model="queryParams"
        ref="queryForm"
        
        v-show="showSearch"
        label-width="68px"
      >
        <div class="global-ser" :class=" !boxClass?'':'open'" id="add">
          <div class="ser-top">
            <div class="cell-left">
              <el-input
                v-model.trim="queryParams.docNames"
                placeholder="输入文件名称搜索"
                @keyup.enter.native="handleQuery"
                class="input-with-select"
              >
                <el-button
                  slot="append"
                  icon="el-icon-search"
                  @click="handleQuery"
                ></el-button>
              </el-input>
              <el-button class="button" @click="activeSearchBox" v-if="!boxClass" >
                <i class="icon iconfont icon-zongheshaixuan-"></i>
                </el-button>
              <el-button v-else class="button" @click="activeSearchBox" style="background: #013288;border-color: #013288;color: #fff;">
                <i class="icon iconfont icon-zongheshaixuan-"></i>
                </el-button>
              <el-button icon="el-icon-refresh"  @click="resetQuery"
                >重置
              </el-button>
            </div>
            <div class="cell-right"></div>
          </div>
          <div class="ser-bottom">
            <div class="cell-left">
                 
                  <el-form-item label="文件类型">
                    <el-select placeholder="文件类型" v-model.trim="queryParams.docClass">
                      <el-option
                          v-for="(item) in fileTypeList"
                          :key="item.id"
                          :label="item.className"
                          :value="item.id">
                        </el-option>
                    </el-select>
                  </el-form-item>
            </div>
            <div class="cell-right">
                <el-button type="primary" @click="handleQuery">查询</el-button>
                <el-button  @click="resetQuery">重置</el-button>
                <el-button  @click="boxClass = false">取消</el-button>
            </div>
        </div>
        </div>
      </el-form>
      <el-card class="gray-card">
        <el-table
          v-loading="loading"
          :data="postList"
          @selection-change="handleSelectionChange"
          header-align="left"
        >
          <el-table-column type="selection" width="55" align="left" />
          <el-table-column
            label="文件类型"
            align="left"
            prop="docClass"
            :show-overflow-tooltip="true"
          >
          <template slot-scope="scope">
              {{ handleFileType(scope.row.docClass) }}
            </template>
          </el-table-column>
          <el-table-column
            label="文件名称"
            align="left"
            width="400"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <span class="wenjcolor" @click="handleOpenDetail(scope.row)">{{ scope.row.docNames }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="文件版本"
            align="left"
            prop="docVersion"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="编制部门"
            align="left"
            prop="makeDeptName"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="借阅时限"
            align="left"
            prop="dayTime"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="到期时间"
            align="left"
            prop="endTime"
            :show-overflow-tooltip="true"
          >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d} {h}:{i}') }}</span>
        </template>
      </el-table-column>

          <el-table-column
            label="操作"
            align="left"
            width="95"
            class-name="small-padding fixed-width"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                @click="handleOpenDetail(scope.row)"
                >详情</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </el-card>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />

      <rz-drawer @changeDrawer="handleClose" class="details-drawer" :drawer="drawer">
        <myloanDetails :detailInfo="detailInfo"></myloanDetails>
      </rz-drawer>
    </div>
  </div>
</template>

<script>

export default {
  name: "Post",
  dicts: ["apply_type"],
  components: {
  },
  data() {
    return {
      deptOptions:[],
      fileTypeList: [],
      boxClass:false,
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 岗位表格数据
      postList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      drawer: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        searchValue: "",
        docClass:null,
        docName:null,
        deptId:null
      },
      detailInfo: {},
    };
  },
  created() {

  },
  methods: {
    handleFileType(obj) {
      if (obj && this.fileTypeList) {
        let arr = this.fileTypeList.filter((x) => x.id === obj)[0];
        if (arr) {
          return arr.className;
        }
        return obj;
      }
    },
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.deptId,
        label: node.deptName,
        children: node.children,
      };
    },
    activeSearchBox(){
      this.boxClass= ! this.boxClass
    },
    /** 查询列表 */
    getList() {

    },
    handleOpenDetail(row) {
      this.title = "详情";
      this.drawer = true;
      this.detailInfo = row;
    },
    handleClose() {
      this.drawer = false;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.searchValue = "";
      this.queryParams.docClass = null;
      this.queryParams.docName = null;
      this.queryParams.deptId = null;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.postId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/post/export",
        {
          ...this.queryParams,
        },
        `post_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>

